//
// Created by liushuai on 2021/2/27.
//

#include "findWords.h"

bool isContain(string &s1, set<char> &s2) {
<<<<<<< HEAD:cxx/algorithm/src/findWords.cc
    bool res = true;
    int i = 0;
    for(;i<s1.size();i++){
        char current = s1[i]|32;
        if(!s2.count(current))
            break;
    }
    if(i != s1.size())
        res = false;
    return res;
}

vector<string> findWords(vector<string> &words) {
    set<char> s1 = {'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p'};
    set<char> s2 = {'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l'};
    set<char> s3 = {'z', 'x', 'c', 'v', 'b', 'n', 'm'};
    vector<string> result;
    for (auto str:words) {
        if (isContain(str, s1) || isContain(str, s2) || isContain(str, s3))
            result.push_back(str);
    }
    return result;
=======
  bool res = true;
  int i = 0;
  for (; i < s1.size(); i++) {
    char current = s1[i] | 32;
    if (!s2.count(current)) break;
  }
  if (i != s1.size()) res = false;
  return res;
}

vector<string> findWords(vector<string> &words) {
  set<char> s1 = {'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p'};
  set<char> s2 = {'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l'};
  set<char> s3 = {'z', 'x', 'c', 'v', 'b', 'n', 'm'};
  vector<string> result;
  for (auto str : words) {
    if (isContain(str, s1) || isContain(str, s2) || isContain(str, s3))
      result.push_back(str);
  }
  return result;
>>>>>>> dev:cxx/algorithm/common/src/findWords.cc
}